import {createApp} from 'vue';
import './assets/style/common.scss';
import App from './App.vue';
import {createPinia} from 'pinia';

import {initWS} from './utils/websocket';

// 从loaction 获取ws端口
const wsConfig = {};
window.location.search.replace('?', '').split('&').forEach(item => {
    const obj = item.split('=');
    wsConfig[obj[0]] = obj[1];
});

const app = createApp(App);
const pinia = createPinia();
app.use(pinia).mount('#app');

const socket = initWS(wsConfig);
app.config.globalProperties.$socket = socket;
